package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IThirdPartyLoginBindPhoneNumberModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName ThirdPartyLoginBindPhoneNumberModel
 * @Description
 * @date 2016-10-13
 * @history 2016-10-13 author: description:
 */

public class ThirdPartyLoginBindPhoneNumberModel extends BaseModel implements IThirdPartyLoginBindPhoneNumberModel, HttpWebServiceCallBack {

    public ThirdPartyLoginBindPhoneNumberModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    /**
     * 第三方登录绑定手机号
     *
     * @param phone    手机号
     * @param smscode  验证码
     * @param uid      id
     * @param nickname 昵称
     * @param avatar   头像
     * @param apptype  第三方平台类型
     */
    @Override
    public void doUserOuterSysBind(String phone, String smscode, String uid, String nickname, String avatar, String apptype) {
        Map<String, String> params = new HashMap<>();
        params.put("phone", phone);
        params.put("smscode", smscode);
        params.put("uid", uid);
        params.put("nickname", nickname);
        params.put("avatar", avatar);
        params.put("apptype", apptype);
        HttpWebService.getDataFromServer(NetConstant.USEROUTERSYSBIND, params, true, this);
    }

    /**
     * 获取验证码
     *
     * @param inputPhone 手机号
     */
    @Override
    public void doGetCode(String inputPhone) {
        Map<String, String> params = new HashMap<>();
        params.put("phone", inputPhone);
        params.put("type", "3");
        HttpWebService.getDataFromServer(NetConstant.TYPE_SMS_CODE, params, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }
}
